#include "sysdef.h"

#include "tbworker.h"

#include "cowwork.h"
#include "cowlogin.h"

void tbapi_test()
{
    printf("tbapi_test start ok\n");

    CTBSyncWorker tbworker("21638100", "4c89d6f0f8f5866e93e492f52b69d53c");

    TBRequest request; tbworker.SetRequest(request, "nick", "taobao.user.seller.get", "test");

    TBResponse response;

    tbworker.Work(request, response);
}

void sync_client_test()
{
    printf("sync client start ok\n");

    CCowLoginRequest request;
    request.m_usertype = "cowid";
    request.m_userid = "1";
    request.m_password = "1";

    CCowLoginResponse response;

    if(sCowWork.SyncWork(&request, &response))
    {
    }
}

bool g_startup = true;

void client_socket_callback(string addrinfo)
{
    g_startup = false;
}

void client_test()
{
    printf("client start ok\n");

    sCowWork.SetClientCallback(client_socket_callback);

    CCowLoginRequest request;
    request.m_usertype = "cowid";
    request.m_userid = "1";
    request.m_password = "1";

    if(sCowWork.PushInCmd(&request))
    {
        CCowLoginResponse response;

        if(sCowWork.GetOutCmd(&response))
        {
        }
    }
}

int main(int argc, char* argv[])
{
    get_arg_params(argc, argv);

    //tbapi_test();

    if(!sCowWork.Start("config.client"))
        return 0;

    while(1)
    {
        //client_test();
        sync_client_test();

        sleep_s(1);
    }

    return 0;
}
